<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.w3.org/1999/xhtml">

<head>
    <th:block th:include="common/common_head :: commonHeader('采购申请头文件')"/>
    <link rel="stylesheet" th:href="@{/static/js/plugins/jquery-layout/jquery.layout-latest.css}">
	<!-- <style type="text/css">.table {table-layout:fixed;}</style> -->
</head>

<body class="gray-bg">

<div class="container-div ui-layout-center">
    <div class="row">
        <div class="col-sm-12 search-condition">
            <form id="nproPurchRequestHeaderForm" th:action="@{/nproPurchRequestHeader/list}" class="form-inline">
                <div class="select-list">
                    <ul>
                        <li class="col-sm-3" style="width: 33%">
                               <label>部门：</label>
                               <select id="purchRequestDept" name="purchRequestDept" sysDict="BM" emptyFirst="true"></select>
                        </li>
                        <li class="col-sm-3" style="width: 33%">
                              <label>成本中心：</label>
                              <select id="costCenter" name="costCenter" sysDict="CBZX" emptyFirst="true"></select>
                        </li>
                        <li class="col-sm-3" style="width: 33%">
	                            <label>采购申请单号：</label>
	                            <input type="text" name="purchRequestCode"/>
                        </li>
                        <li class="col-sm-3" style="width: 33%">
                            <div>
	                            <label>申请者：</label>
	                            <input type="text" name="purchRequestStaff"/>
                            </div>
                        </li>
                        <li class="col-sm-3" style="width: 33%">
                            <label>需求日期(起)：</label>
                            <input type="text" name="requestDate" id="requestDate"/>
                        </li>
                        <li class="col-sm-3" style="width: 33%">
	                            <label>需求日期(止)：</label>
	                            <input type="text" name="deliveryDate" id="deliveryDate"/>
                        </li>
                        
                        <li class="col-sm-3" style="width: 33%">
                            <button id="nproPurchRequestHeaderSearchBtn" type="button" class="btn btn-primary btn-rounded btn-sm"><i class="fa fa-search"></i>&nbsp;搜索</button>
                            <button class="btn btn-warning btn-rounded btn-sm" type="reset"><i class="fa fa-eraser"></i>&nbsp;重置</button>
                            <button id="nproPurchRequestHeaderAdvancedSearch" type="button" class="btn btn-primary btn-rounded btn-sm" style="display: none"><i class="fa fa-caret-down"></i>&nbsp;高级搜索</button>
                        </li>
                    </ul>
                </div>
            </form>
        </div>
        
        <div class="col-sm-12 select-info order-table">
            <div class="btn-group hidden-xs toolbar" id="nproPurchRequestHeaderToolBar" role="group">
                <a class="btn btn-outline btn-success btn-rounded" onclick="toAddnproPurchRequestHeader()">
                    <i class="fa fa-plus"></i> 新增
                </a>
                <a class="btn btn-outline btn-success btn-rounded" onclick="toEditnproPurchRequestHeader()">
                    <i class="fa fa-edit"></i> 编辑
                </a>
            </div>
            <div style="height:360px; overflow:auto;">
            	<table id="nproPurchRequestHeader" data-mobile-responsive="true"></table>
            </div>
            <div>
            	<table id="nproPurchRequestItem" data-mobile-responsive="true"></table>
            </div>
        </div>
    </div>

</div>
<!--引入公共js-->
<div th:include="common/onload_js :: onloadJS"></div>
<script type="text/javascript" th:src="@{/static/js/plugins/jquery-layout/jquery.layout-latest.js}"></script>

<!-- Page-Level Scripts -->

<!--  -->
<script type="text/javascript">
	var itemBS = Searcher.createBS('#nproPurchRequestItem',
	        [
	            {checkbox: true},
	            {title: "采购申请编码", field:"purchRequestCode"},
	            {title: "采购申请行项目编码",field:"purchRequestItemCode"},
	            {title: "货源状态",field:"goodsStatus"},
	            {title: "科目类别",field:"subjectCategory"},
	            {title: "采购组",field:"purchGroup"},
	            {title: "采购组织",field:"purchOrg"},
	            {title: "使用人",field:"purchRequestItemCode"},
	            {title: "物料描述",field:"materialDesc"},
	            {title: "工厂",field:"factory"},
	            {title: "库存地点",field:"storageLocation"},
	            {title: "物料组",field:"materialGroup"},
	            {title: "申请数量",field:"applyQty"},
	            {title: "计量单位",field:"measureUnit"},
	            {title: "成本中心",field:"costCenter"},
	            {title: "内部订单号",field:"internalOrderCode"},
	            {title: "主资产号",field:"mainAssetsCode"},
	            {title: "资产次级编号",field:"assetsSencondCode"},
	            {title: "需求日期",field:"requestDate"},
	            {title: "交货日期",field:"deliveryDate"},
	            {title: "交货地址",field:"deliveryAddress"},
	            {title: "备注",field:"remark"}
	        ], {"showColumns": false,"showRefresh": false, "firstLoad": false}
	);
  
    //面向对象
    var searcherBS= Searcher.createBS('#nproPurchRequestHeader',
        [
            {radio: true},
            {title: "采购申请编码", field:"purchRequestCode"},
            {title: "采购申请类型 ",field:"purchRequestType"},
            {title: "创建人",field:"purchRequestStaff"},
            {title: "申请部门",field:"purchRequestDept"},
            {title: "流程状态",field:"apprStatus"}
        ], {pageList: [5, 10, 15, 50, 100], pageSize : 5,
    	onCheck : function(row) {itemBS.getData({'url': ctxPath + '/nproPurchRequestItem/list?purchRequestCode='+row.purchRequestCode});},
    	onPostBody : function() {$("#nproPurchRequestItem").bootstrapTable('removeAll');}
    	}
    );
    //刷新数据
    function refresh() {
    	searcherBS.refresh();
    }
    
    // 初始化时间插件
    laydate.render({elem: '#requestDate'});
    laydate.render({elem: '#deliveryDate'});
    
    initDictDataSel();//初始化所有字典数据
    /**
     * 跳转至新增页
     */
    function toAddnproPurchRequestHeader() {
        var index=Dialog.openUrl("新增采购订单", ctxPath + '/modules/requisition/requisition_add.html',{area : ['900px','700px'],
            maxmin: true,
            end: function() {}
        });
        layer.full(index);
    }
 
    /**
     * 编辑
     */
    function toEditnproPurchRequestHeader() {
    	//field:"pkId"
        var rowDatas = searcherBS.getSelectedRows("pkId");
        if (rowDatas.length != 1) {
            Dialog.errorMsg("请选择一行进行编辑");
            return;
        }
		var index = Dialog.openUrl("编辑供应商信息", ctxPath + '/nproPurchRequestHeader/toEdit/'+rowDatas,
		    {area : ['900px','700px'],
			  maxmin: true,
		      end: function () {}
		    });
		layer.full(index)
    }

    function deletePurchRequestHeader() {
        var rowDatas = searcherBS.getSelectedRows("pkId");
        if (rowDatas.length < 1) {
            Dialog.errorMsg("请至少选择一行");
            return;
        }
        Dialog.confirm('确定删除？', function(index){
            Page.ajaxPOST(ctxPath + "/nproPurchRequestHeader/delete", {userIds: rowDatas}, function () {
                Dialog.msg("操作成功", function () {
                    searcherBS.refresh();
                });
            });
        });
    }
</script>
</body>
</html>